package com.junzhiit.nengji.api.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.junzhiit.nengji.api.service.PromotionPosterService;
import com.junzhiit.nengji.api.web.vo.ListVO;
import com.junzhiit.nengji.api.web.vo.PromotionPosterVO;
import com.junzhiit.nengji.bo.PromotionPosterBO;
import com.junzhiit.nengji.dao.PromotionPosterDAO;

@Service
public class PromotionPosterServiceImpl  extends BaseServiceImpl implements PromotionPosterService {

	@Autowired 
	private PromotionPosterDAO promotionPosterDAO;
	
	@Override
	public ListVO findList(String csId,Integer type,int pageNumber, int maxPageRow) {
		List<PromotionPosterBO> list = promotionPosterDAO.findPageAll(csId,type, pageNumber, maxPageRow);
		List<PromotionPosterVO> voList = new ArrayList<PromotionPosterVO>();
		for(PromotionPosterBO promotionPosterBO : list){
			PromotionPosterVO  promotionPosterVO = new PromotionPosterVO();
			BeanUtils.copyProperties(promotionPosterBO,promotionPosterVO);
			voList.add(promotionPosterVO);
		}
		int count = promotionPosterDAO.totalCount(csId, type);
		ListVO listVO = new ListVO();
		listVO.setIndex(pageNumber);
		listVO.setCount(count);
		listVO.setList(voList);
		return listVO;
	}

}
